import request from "@/utils/request";

/**
 * 获取系统日志列表
 * @param page 页码
 * @param pageSize 每页数量
 * @param data 查询参数
 * @returns
 */
export const getLogList = (
  page: number,
  pageSize: number,
  data?: {
    title?: string;
    operName?: string;
    businessType?: string;
    beginDateTime?: string;
    endDateTime?: string;
    status?: number;
  }
) => {
  return request({
    url: `/sys/log/${page}/${pageSize}`,
    method: "post",
    data: data || {}
  });
};

/**
 * 导出日志
 * @param data 查询参数
 * @returns
 */
export const exportLog = (data?: {
  title?: string;
  operName?: string;
  businessType?: string;
  beginDateTime?: string;
  endDateTime?: string;
  status?: number;
}) => {
  return request({
    url: "/admin/sys/log/export",
    method: "post",
    data: data || {},
    responseType: "blob"
  });
};

/**
 * 清空日志
 * @returns
 */
export const clearLog = () => {
  return request({
    url: "/admin/sys/log/clean",
    method: "delete"
  });
};
